package com.ec.log.modules.log.controller;

import com.ec.core.common.core.api.Result;
import com.ec.core.common.core.api.ResponseMsg;
import com.ec.core.common.core.base.BasePageVO;
import com.ec.core.log.annotations.OperLog;
import com.ec.core.secure.annotations.PreAuth;
import com.ec.log.modules.log.dto.QueryLogDTO;
import com.ec.log.modules.log.service.ISysLogService;
import com.ec.log.modules.log.vo.SysLogVO;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 日志接口
 * @author: Eric Lee
 * @time: 2021/9/23 16:21
 */
@RestController
@RequestMapping("/log")
public class SysLogController {
    @Resource
    private ISysLogService sysLogService;

    /**
     * 查看列表
     *
     * @param listLogDTO
     * @return
     */
    @GetMapping("/list")
    @PreAuth("sys_log_view")
    public Result<BasePageVO<SysLogVO>> listLog(QueryLogDTO listLogDTO) {
        return ResponseMsg.success(sysLogService.listLog(listLogDTO));
    }

    /**
     * 删除操作
     *
     * @param logId
     * @return
     */
    @DeleteMapping("/{logId}")
    @PreAuth("sys_log_delete")
    @OperLog(desc = "删除日志")
    public Result<BasePageVO<SysLogVO>> removeLog(@PathVariable Long logId) {
        return ResponseMsg.status(sysLogService.removeLog(logId));
    }

}
